/*
 *  Copyright (C) 2011 glauco
 *
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package org.balisunrise.swing.commons.listeners;

import java.util.ArrayList;
import java.util.List;
import org.balisunrise.common.Action;
import org.balisunrise.common.Event;

/**
 *
 * @author Glauco
 */
public class EntityActionsListener
        implements org.balisunrise.common.listeners.EntityActionsListener{

    private List<Action> vap;
    private List<Action> bConfim;
    private List<Action> bCancel;

    public EntityActionsListener() {
        vap = new ArrayList<Action>();
        bConfim = new ArrayList<Action>();
        bCancel = new ArrayList<Action>();
    }

    public void addVisualActinPerformedAction(Action action){
        if(vap.contains(action))
            return ;
        vap.add(action);
    }

    public void addBeforeConfirmAction(Action action){
        if(bConfim.contains(action))
            return ;
        bConfim.add(action);
    }

    public void addBeforeCancelAction(Action action){
        if(bCancel.contains(action))
            return ;
        bCancel.add(action);
    }

    @Override
    public void visualActionPerformed(Event event) {
        for (Action action : vap) {
            action.perform(event);
        }
    }

    @Override
    public void beforeConfirm(Event event) {
        for (Action action : bConfim) {
            action.perform(event);
        }
    }

    @Override
    public void beforeCancel(Event event) {
        for (Action action : bCancel) {
            action.perform(event);
        }
    }

}
